package com.hyjx.framework.common;

import com.hyjx.framework.common.tree.TreeObject;
import com.hyjx.framework.component.codetable.CodeBean;
import com.hyjx.framework.component.codetable.CodeTableInfo;
import com.hyjx.framework.component.codetable.CodeTableManager;

import java.util.ArrayList;
import java.util.List;


/**
 * 自定义tree处理器
 */
public class ConfigParentTree {

    /**
     * 获取某个树数据，可指定树根和是否采用缓冲技术
     *
     * @param treeID
     * @param root
     * @param useCache
     * @return
     */
    @SuppressWarnings("rawtypes")
    public static List getTreeData(String treeID, String root, boolean useCache) {
        List<TreeObject> list = new ArrayList<TreeObject>();
        CodeTableInfo info = CodeTableManager.getCodeTableMap().get(treeID);

        if (info != null) {
            List<CodeBean> tmpList = info.getCodeList();

            for (CodeBean cb : tmpList) {
                TreeObject to = new TreeObject();
                to.setParent_id(cb.getParentCode());
                to.setText(cb.getName());
                to.setId(cb.getCode());
                list.add(to);
            }
        }
        return list;
    }
}